if(!Apps) var Apps = {};
var Acity_complete = 0,Acity_total = 0;
//初始化
Apps.storage = function(Did,objname,css,columns,url){
	if(!Did) Did='Astorage';
	this.Did = Did;
	if(css) this.css = css;
	this.columns = columns;
	this.objname = objname;
	this.url = url;
}
Apps.storage.prototype = new Apps.storage();
Apps.storage.prototype.show = function(Did,title,html,css){
	if(!this.Did){this.Did = 'ajax_list';}
	if(!obj){var obj=Object();}
	obj.id=this.Did;
	if(Did) obj.id += Did;
	obj["class"]='acan_win dis_none';
	obj.css={height:'auto',width:'auto'};
	if(css){obj.css=css}
	obj._close={onclick:'Acan.close(\''+obj.id+'\')','class':'-close'};//关闭按钮
	Acan.base.win(obj,title,html);
	//Acan.ajax_bg();
	return jQuery("#"+obj.id+" ._content");
}
Apps.storage.prototype.list = function(){
	var html = '';
	html = Ahtml.tag('tr',{},
		Ahtml.tag('th',{"style":"width:100px"},'key')+
		Ahtml.tag('th',{},'val')+
		Ahtml.tag('th',{"style":"width:120px"},Ahtml.tag('input',{type:"text",name:"city",size:4})+Ahtml.tag('button',{"onclick":"Aui_add()"},'添加'))
	);
	var keys = Acan.storage.keys();
	for(var i in keys){
		if(keys[i]=='citymap' || keys[i]=='distmap') continue;
		html += Ahtml.tag('tr',{"class":""},
			Ahtml.tag('td',{},keys[i])+
			Ahtml.tag('td',{},this.getval(keys[i]))+
			Ahtml.tag('td',{},
				Ahtml.tag('button',{"onclick":"Aui_start('"+keys[i].split('_')[1]+"',1)"},'启动')+
				Ahtml.tag('button',{"onclick":"Aui_start('"+keys[i].split('_')[1]+"')"},'继续')+
				Ahtml.tag('button',{"onclick":"Aui_stop('"+keys[i].split('_')[1]+"')"},'停止')+
				Ahtml.tag('button',{"onclick":"Astorage.edit('"+keys[i]+"')"},'编辑')+
				Ahtml.tag('button',{"onclick":"Astorage.del('"+keys[i]+"')"},'删除')
			)
		);
	}
	html = Ahtml.tag('table',{"class":"-table"},html);
	this.show('list','本地存储列表',html,{width:'600px',height:'400px'});
}
Apps.storage.prototype.getval = function(key){
	var obj = Acan.storage.get(key),str='';
	if(typeof(obj)=='object'){
		str=JSON.stringify(obj);
	}else{
		str = obj;
	}
	return str;
}
Apps.storage.prototype.edit = function(key){
	var val = Acan.storage.get(key);
	if(typeof(val)=='object') val = JSON.stringify(val);
	var html = '';
	html = Ahtml.tag('tr',{},
		Ahtml.tag('td',{"width":"20"},"KEY:")+
		Ahtml.tag('td',{"width":"80"},Ahtml.tag('input',{type:"text","name":"key",value:key}))
	)+
	Ahtml.tag('tr',{"class":""},
		Ahtml.tag('td',{"class":""},"值:")+
		Ahtml.tag('td',{"class":""},Ahtml.tag('textarea',{"name":"val","style":"width:200px;height:100px;"},val))
	)+
	Ahtml.tag('tr',{"class":""},
		Ahtml.tag('td',{"colspan":"2"},Ahtml.tag('button',{"onclick":"Astorage.save('"+key+"')"},'保存'))
	)
	html = Ahtml.tag('table',{"class":"-table","id":"Astorage_"+key},html);
	this.show('edit','编辑'+key,html,{width:'300px',height:'200px'});
}
Apps.storage.prototype.save = function(key){
	var fobj = jQuery('#Astorage_'+key);
	var k = fobj.find('input[name="key"]').val();
	var v = fobj.find('textarea[name="val"]').val();
	if(Acan.base.in_array(v[0],['{','[','"'])){v = JSON.parse(v);}/*}*/
	Acan.storage.del(key);
	Acan.storage.set(k,v);
	Acan.alert('保存成功',1000);
	this.list();
}
Apps.storage.prototype.del = function(key){
	if(!confirm('确实要删除 '+key+' 吗?')){return false;}
	Acan.storage.del(key);
	Acan.alert('删除成功',1000);
	this.list();
}


function getck(){
	var cookie = "BIGipServerPool_common=2042691850.36895.0000; BIGipServerPool_expquery=2462777610.30755.0000; BIGipServerPool_mat=1136787722.32035.0000; BIGipServerPool_mdm=1153564938.30755.0000; BIGipServerPool_ord=1388445962.30755.0000; BIGipServerPool_stl=1153564938.31523.0000; JSESSIONID=0000zgxV4aGoZNKC70uyfXXRy01:17qp82fjk; TOKEN=8a8142c43e4fa032013e5fbb4e730596|PqTflP07Jie2hSI_aWkoKdc|exp";
	var crr = cookie.split('; '),obj={};
	for (var i in crr) {
		var krr = crr[i].split('=');
		obj[krr[0]] = krr[1];
	};
	return obj;
}
function Aui_init(cb){
	if(!Acan.storage.get('citymap') || !Acan.storage.get('distmap')){
		var province={},city={},dist={},ci=0;
		var area = dsy.Items;
		for (var i in area) {
			var id = i.split('_');
			if(id.length==1){
				privince = area[i];
			}else if(id.length==2){
				for (var x in area[i]) {
					city[area[i][x]] = privince[id[1]];
				};
			}else if(id.length==3){
				dist[area[id[0]+'_'+id[1]][id[2]]] = area[i];
			}
		};
		Acan.storage.set('citymap',city);
		Acan.storage.set('distmap',dist);
	}
	Acitymap = Acan.storage.get('citymap');
	Adistmap = Acan.storage.get('distmap');
	if(!Acan.storage.get('cookie_yto')){Acan.storage.set('cookie_yto',Agl.cookie_yto);}
	if(!Acan.storage.get('发货城市')){Acan.storage.set('发货城市','北京');}
	if(!Acan.storage.get('114用户名')){Acan.storage.set('114用户名','');}
	if(!Acan.storage.get('114密码')){Acan.storage.set('114密码','');}
	if(!Acan.storage.get('刷新周期')){Acan.storage.set('刷新周期',Agl.reload);}
	if(!Acan.storage.get('发布时间')){Acan.storage.set('发布时间',Agl.sendtime);}
	if(Acan.storage.get('自动开始')=='开启'){setTimeout(function(){Arun();},2000);}
	/*
	if(jQuery("#Aui").length<1){
		var html = '';
		html = Ahtml.tag('div',{"class":"_box"},
			Ahtml.tag('ul',{"class":"_menu"},
				Ahtml.tag('li',{"class":"",onclick:"Astorage.list()"},'设置')+
				Ahtml.tag('li',{"class":"",onclick:"Arun()"},'开始')+
				Ahtml.tag('li',{"class":"",onclick:"Aui_reload()"},'刷新')+
				Ahtml.tag('li',{"class":"",onclick:"Aui_login()"},'登入114')
			)
		);
		html = Ahtml.tag('div',{"class":"Aui","id":"Aui"},html);
		jQuery("body").after(html);
	}*/
	setTimeout(function(){
		if(cb) cb();
	},200);
}
function refresh_114(type){
	if(type && type==1){
		Acan.storage.set('114用户名',jQuery('#login_114 input[name="name"]').val());
	}
	if(Acan.storage.get('114用户名')==''){return;}
	//jQuery('#code_114').attr('src',Agl.login114.verify+(new Date()).getTime());
	jQuery('#code_114').attr('src',Acan.url.uni({
		0:Agl.proxy,
		url:escape(Agl.login114.verify+(new Date()).getTime()),
		Asid:Acan.storage.get('114用户名')
		//cookie:escape(Acan.storage.get('cookie_114'))
	}));
}
function Aui_login(){
	var title = '114登入';
	var html = '<form id="login_114" action="/login" method="get" onsubmit="login_114();return false;"><table>'
		+'<tr><td>用户名：</td><td><input type="text" class="input-block-level" placeholder="用户名" name="name" value="'+Acan.storage.get('114用户名')+'" onchange="refresh_114(1)"></td></tr>'
		+'<tr><td>密码：</td><td><input type="text" class="input-block-level" placeholder="密码" name="pwd" value="'+Acan.storage.get('114密码')+'"></td></tr>'
		+'<tr><td>验证码：</td><td><input type="text" class="span1" placeholder="验证码" name="code"></td></tr>'
		+'<tr><td><img class="code" id="code_114" src="" onclick="refresh_114();"></td><td>'
		+'<input type="hidden" name="token" value="'+(new Date()).getTime()+'"/>'
		+'<input type="submit" value="登入"></td></tr></table></form>';
	html += '';
	Did = 'ajax_login';
	var obj=Object();
	if(Did) obj.id = Did;
	obj["class"]='acan_win dis_none';
	obj.css={height:'auto',width:'auto'};
	obj._close={onclick:'Acan.close(\''+obj.id+'\')','class':'-close'};//关闭按钮
	Acan.base.win(obj,title,html);
	refresh_114();
	return ;
}
function login_114(){
	var arr = jQuery('#login_114').serialize();
	Acan.storage.set('114用户名',jQuery('#login_114 input[name="name"]').val());
	jQuery.ajax({
		type:'post',
		url:Acan.url.uni({0:Agl.proxy,method:'POST','url':escape(Agl.login114.login_url),
			Asid:Acan.storage.get('114用户名'),
			'Content-Type':'application/x-www-form-urlencoded',
			'Origin':"http://www.dan114.com",
			'Referer':"http://www.dan114.com/login.jsp"
		}),
		data:arr,
		success: function(data){//成功
			if(data.indexOf('<title>淘单114 用户登录</title>')>0){
				Acan.alert('登入失败',2000);
				refresh_114();
			}else{
				Acan.alert('登入成功',1000)
				Acan.close('ajax_login');
			}
		}
	});
	return false;
}
function find_city(addr,city){
	if(typeof(addr)!='string') return false;
	var str = '';
	for(var i in Acitymap){
		if(addr.indexOf(i)>0){
			if(city && str==city){
				return true;
			}
			str = i;
		}
	}
	if(str==''){
		return false;
	}
	return str;
}
function find_dist(city,addr){
	if(typeof(addr)!='string') return false;
	var str = '';
	for(var i in Adistmap[city]){
		if(addr.indexOf(Adistmap[city][i])>0){
			str = Adistmap[city][i];
		}
	}
	if(str==''){
		str = Adistmap[city][0];
	}
	return str;
}
function post_data(city,obj,type){
	if(!type) type=1;
	var msg = '';
	if(type>1){msg=type+'重试，';}
	Did="Apost"+city;
	if(jQuery('#'+Did).length<1){
		var html = '<div id="'+Did+'" class="Apost">'+city+'</div>';
		jQuery('#Aui').append(html);
	}
	jQuery.ajax({
		type:'post',
		url:Agl.post_url,
		data:{"city":city,"data":JSON.stringify(obj),'index':Aconf[city].index,'page':Aconf[city]['page']},
		success: function(data){//成功
			if(typeof(data)=='object' && data.status==1){
				jQuery('#'+Did).html(msg+city+data.msg);
				if(data.cb && data.cb=='stop'){
					Acity_complete++;
					console.log('已经完成',city,Acity_total,Acity_complete);
					Aui_stop(city,1);
					var city_next = Acity.pop();
					if(city_next){
						if(city_next.length>1) Aui_start(city_next,1);
					}
				}
			}else{
				jQuery('#'+Did).text(msg+city+data);
			}
			if(!city_chk(city,1)){return;}
			if(!Aconf[city].index) Aconf[city].index=1;
			if(data.next==1) Aconf[city].index++;
			Acan.storage.set('conf_'+city,Aconf[city]);
			city_get(city,Aconf[city].index,Aconf[city].page);
		},
		error: function(){//失败重新请求
			if(!city_chk(city,1)){return;}
			post_data(city,obj,type+1);
		}
	})
	/*
	if(jQuery('#'+Did).length>0){
		jQuery('#'+Did).remove();
	}
	var html = '<iframe id="'+Did+'" class="Apost"></iframe>';
	jQuery('#Aui').append(html);
	var cbj = jQuery('#'+Did).contents();
	cbj.find('body').html('<form action="'+url+'" method="post"><input type="text" name="city" value="'+city+'" style="width:40px"><input type="text" name="data" style="width:3px"></form>');
	cbj.find('form input[name="data"]').val(JSON.stringify(data));
	cbj.find('form').submit();
	*/
}
function post_114(city,data,ltime){
	var obj={},lasttime=(Acan.time("s")-3600);
	var province = Acitymap[city],si=0,sendtime,sendtime2;
	Atimer = Acan.storage.get('Atime');
	if(Atimer[city]){
		lasttime=Acan.time("s",Atimer[city]);
	}
	if(!province){post_114_end(city,ltime);return;}
	for(var i in data){
		if(data[i].send['业务类型']!='淘宝 推荐物流' || data[i].order['运单号'].length<2 || Acan.time("s",data[i].send['客户下单时间'])<lasttime){
			delete data[i];continue;
		}
		var dist = find_dist(city,data[i].send['发货人地址']);
		var city2 = find_city(data[i].recv['收货人地址']);
		var wangdian = '',citychk,province2,dist2;
		if(data[i].status['预分配网点']) wangdian = data[i].status['预分配网点'];
		if(data[i].status['接单网点'] && wangdian=='') wangdian = data[i].status['接单网点'];
		if(wangdian!='') citychk = find_city(wangdian,city);
		if(citychk==city && city2){
			province2 = Acitymap[city2];
			dist2 = find_dist(city2,data[i].recv['收货人地址']);
		}else{delete data[i];continue;}
		if(province && city && city2 && dist && province2 && dist2){
			if(Acan.storage.get('发布时间')=='911'){
				sendtime = Acan.time('Y-m-d H:i',Acan.time("s",data[i].send['客户下单时间']));
			}else{
				//if(si%3==2){si++;continue;}si++;
				sendtime = Acan.time('Y-m-d',Acan.time("s",data[i].send['客户下单时间']))+' '+Acan.storage.get('发布时间');
				sendtime2 = Acan.time('Y-m-d H:i',Acan.time("s",data[i].send['客户下单时间']));
			}
			var order = {
				's2':city,'s3':dist,'t2':city2,'t3':dist2,'s1':province,'t1':province2,
				'token':(new Date()).getTime(),'num':data[i].order['运单号'],'type':'yuantong',
				'ss0':'','ss1':'','ss2':'',
				'date1':sendtime,
				'realdate1':sendtime2
			};
			delete data[i];
			send_114(order,function(){
				if(Acan.count(data)>0){
					post_114(city,data,ltime);
				}else{
					post_114_end(city,ltime);
				}
			});
			return;
		}else{
			delete data[i];
		}
	}
	post_114_end(city,ltime);
}
function post_114_end(city,ltime){
	Acity_complete++;
	Atime[city] = ltime;Acan.storage.set('Atime',Atime);
	console.log('完成',city,Acity_total,Acity_complete);
	setTimeout(function(){
		Aui_stop(city,1);
		var city_next = Acity.pop();
		if(city_next){
			if(city_next.length>1) Aui_start(city_next,1);
		}
	},100);
	if(Acity_complete==Acity_total){
		setTimeout(function(){Aui_reload();},Acan.storage.get('刷新周期'));
	}
}
function send_114(obj,cb,type){
	if(!type) type=1;
	var msg = '';
	if(type>1){msg=type+'重试，';}
	jQuery.ajax({
		type:'post',
		timeout:4000,
		url:Acan.url.uni({0:Agl.proxy,method:'POST','url':escape(Agl.login114.send_url),
			Asid:Acan.storage.get('114用户名'),
			'Content-Type':'application/x-www-form-urlencoded',
			'Origin':"http://www.dan114.com",
			'Referer':"http://www.dan114.com/jsp/add2.jsp?r=1"
		}),
		data:obj,
		success: function(data){//成功
			if(data.indexOf('恭喜您，发布成功！您可以继续发布')>0){
				console.log(msg+'发布成功',obj.s1+' '+obj.s2+' '+obj.s3+' '+obj.t1+' '+obj.t2+' '+obj.t3,obj);
			}else if(data.indexOf('此单号已经发布，不能重复发布')>0){
				console.log(msg+'此单号已经发布',obj.s1+' '+obj.s2+' '+obj.s3+' '+obj.t1+' '+obj.t2+' '+obj.t3,obj);
			}else{
				console.log(msg+'失败',obj.s1+' '+obj.s2+' '+obj.s3+' '+obj.t1+' '+obj.t2+' '+obj.t3,obj);
			}
			if(cb) cb();
		},
		error: function(){
			if(type<4){
				setTimeout(function(){send_114(obj,cb,1+type);},500);
			}else{
				console.log(msg+'连接失败',obj.s1+' '+obj.s2+' '+obj.s3+' '+obj.t1+' '+obj.t2+' '+obj.t3,obj);
				if(cb) cb();
			}
		}
	});
}
//关闭确认
function close_old(){
	jQuery('.ui-dialog').each(function(i){
		if(jQuery(this).css('display')=='block'){
			jQuery(this).find('button').click();
		}
	});
}
var Atabs;
function Arun_ready(str){
	if(!str) str='自动发布';
	if(jQuery("#Aui_m").length<1){
		var title = str+'<span></span>',html='';
		html = '<div id="Aui_tabs"><ul></ul></div>';
		var obj=Object();
		var windows = jQuery(window);
		obj.id="Aui_m";
		obj["class"]='acan_win dis_none';
		obj.css={height:windows.height()-20,width:windows.width()-160,"z-index":10};
		obj._close={onclick:'Acan.close(\''+obj.id+'\')','class':'-close'};//关闭按钮
		Acan.base.win(obj,title,html);
		//Acan.ajax_bg();
jQuery(function() {
	Atabs = jQuery( "#Aui_tabs" ).tabs({event: "mouseover"});
	// modal dialog init: custom buttons and a "close" callback reseting the form inside
	var dialog = jQuery( "#dialog" ).dialog({
		autoOpen: false,modal: true,buttons: {Add: function() {addTab();jQuery( this ).dialog( "close" );},
		Cancel: function() {jQuery( this ).dialog( "close" );}},close: function() {form[ 0 ].reset();}
	});
	// addTab form: calls addTab function on submit and closes the dialog
	var form = dialog.find( "form" ).submit(function( event ) {
		addTab();dialog.dialog( "close" );event.preventDefault();
	});
	// addTab button: just opens the dialog
	jQuery( "#add_tab" ).button().click(function() {dialog.dialog( "open" );});
	// close icon: removing the tab on click
	Atabs.delegate( "span.ui-icon-close", "click", function() {
		var panelId = jQuery( this ).closest( "li" ).remove().attr( "aria-controls" );
		jQuery( "#" + panelId ).remove();
		Atabs.tabs( "refresh" );
	});
	Atabs.bind( "keyup", function( event ) {
		if ( event.altKey && event.keyCode === jQuery.ui.keyCode.BACKSPACE ) {
			var panelId = Atabs.find( ".ui-tabs-active" ).remove().attr( "aria-controls" );
			jQuery( "#" + panelId ).remove();
			Atabs.tabs( "refresh" );
		}
	});
});
	}else{
		jQuery("#Aui_m").removeClass('dis_none');
	}
}
function Aui_start(city,type){
	Arun_ready();
	Aconf[city] = Acan.storage.get('conf_'+city);
	if(!Aconf[city]){
		Acan.storage.set('conf_'+city,Agl.conf);
		Aconf[city] = Acan.storage.get('conf_'+city);
	}
	if(type==1){
		Aconf[city].index=0;
		Acan.storage.set('conf_'+city,Aconf[city]);
	}else{
		Aconf[city].index--;
		Acan.storage.set('conf_'+city,Aconf[city]);
	}
	jQuery("#ss_"+city).text(Aconf[city].index);
	if(jQuery('#cid_'+city).length<1){
		var html = '<div id="cid_'+city+'" rel="'+city+'">'+city+'加载中…</div>';
		Aui_addTab(city,html);
		city_get(city,Aconf[city].index,Aconf[city].page);
	}
	if(Aconf[city].status!=1){
		Aconf[city].status = 1;
		Acan.storage.set('conf_'+city,Aconf[city]);
		city_get(city,Aconf[city].index,Aconf[city].page);
	}
}
function Aui_stop(city,type){
	if(Aconf[city]){
		Aconf[city].status = 2;
		Acan.storage.set('conf_'+city,Aconf[city]);
	}
	if(type && type==1){
		delete Aconf[city];
		setTimeout(function(){
			Aui_closeTab(city);
			Acan.storage.del('conf_'+city);
			if(jQuery('#Aui_tabs > div').length<1){
				//setTimeout(function(){window.location.reload();},600*1000);
			}
		},500);
		setTimeout(function(){jQuery('#Apost'+city).remove();},500);
	}
}
function Aui_add(){
	var city = jQuery('#Astoragelist input[name="city"]').val();
	Acan.storage.set('conf_'+city,Agl.conf);
	Astorage.list();
}
function Arun_stop(){
	Acan.storage.set('自动开始','停止');
}
function Arun(){
	Acan.storage.set('自动开始','开启');
	Acity = Acan.storage.get('发货城市').split(' ');
	Acity_total = Acity.length;
	for (var i=0; i < 4; i++) {
		var city = Acity.pop();
		if(city && city.length>1) Aui_start(city,1);
	};
}
function add_city(){
	var city = jQuery('#s2').val(),add=true;
	if(city=='市级') return;
	Acity = Acan.storage.get('发货城市').split(' ');
	for (var i in Acity) {
		if(Acity[i]==city){add=false;}
	}
	if(add){
		Acity.push(city);
		Acan.storage.set('发货城市',Acity.join(' '));
		Acan.alert('添加成功');
	}else{
		Acan.alert('已经存在');
	}
}
function city_chk(city,type){
	if(!Aconf[city] || Aconf[city].status!=1){return false;}
	if(!Aconf[city].max) Aconf[city].max=0
	if(Aconf[city].max>0 && Aconf[city].index>Aconf[city].max){
		Aconf[city].status=3;
		Acan.storage.set('conf_'+city,Aconf[city]);
		Aui_stop(city,type);
		return false;
	}
	return true;
}
function city_get(city,index,page){
	if(!city_chk(city)){return;}
	Aconf[city] = Acan.storage.get('conf_'+city);
	if(!Aconf[city]){
		Aconf[city] = Agl.conf;
		Acan.storage.set('conf_'+city,Aconf[city]);
	}
	var obj = jQuery('#cid_'+city);
	obj.html('加载中…');
	var url = Agl.search_url.replace('conditionText=','conditionText='+city)+Math.random();
	if(index){
		url = url.replace('pageIndex=0','pageIndex='+index);
	}
	if(!page){page = Aconf[city].page;}
	url = url.replace('pageSize=100','pageSize='+page);
	jQuery("#ss_"+city).text(Aconf[city].index);
	if(obj.length>0){
		jQuery.get(Agl.proxyl,{"url":url,'cookie':Acan.storage.get('cookie_yto')},function(data){
				setTimeout(function(){city_chuli(city,index);},1000);
				document.getElementById('cid_'+city).innerHTML = data;
		});
	}
}
function search_city(){
	Arun_ready('搜索');
	var page = 100;
	var city = jQuery('#search_city input[name="city"]').val();
	//var page = jQuery('#search_city input[name="page"]').val();
	var url = Agl.search_url.replace('conditionText=','conditionText='+city)+Math.random();
	url = url.replace('pageSize=100','pageSize='+page);
	jQuery.get(Agl.proxyl,{"url":url,'cookie':Acan.storage.get('cookie_yto')},function(data){
		document.getElementById('Aui_tabs').innerHTML = data;
	});
	
	return false;
}
function proxy_open(url,name){
	var tmp = url.split("http://")[1];
	var host = tmp.substr(0,tmp.indexOf('/'));
	var path = tmp.substr(0,tmp.lastIndexOf('/')+1);
	Arun_ready('代理访问');
	if(!name){
		name = jQuery('#Aui input[name="name"]').val();
		if(name=='') name = Acan.storage.get('114用户名');
	}
	jQuery.get(Agl.proxy,{"url":url,Asid:name,'Referer':url},function(data){
		document.getElementById('Aui_tabs').innerHTML = data;
		jQuery('#Aui_tabs a').each(function(i){
			var href = jQuery(this).attr('href').replace(':80','');
			jQuery(this).removeAttr('target');
			if(href.substr(0,4)!='http'){
				if(href[0]=='/'){
					href = "http://"+host+href;
				}else{
					href = "http://"+path+href;
				}
			}
			jQuery(this).attr('href','javascript:proxy_open(\''+href+'\',\''+name+'\')');
		})
	});
		/*Acan.url.uni({0:Agl.proxy,method:'POST','url':escape(Agl.login114.send_url),
			Asid:Acan.storage.get('114用户名'),
			'Content-Type':'application/x-www-form-urlencoded',
			'Origin':"http://www.dan114.com",
			'Referer':"http://www.dan114.com/jsp/add2.jsp?r=1"
		})*/
}
function Aui_reload(){
	window.location.reload();
	//window.open(document.location.href,Math.floor(Math.random()*100));
	//setTimeout('window.close()',1000);
}
function Aui_shuaxin(city,time){
	if(time>0){
		setTimeout(function(){Aui_shuaxin(city,time-1)},1000);
		jQuery("#ss_"+city).text(time-1);
	}
}
function city_chuli(city,index){
	var lasttime;
	var tbj = jQuery('#cid_'+city+' table .order_toolbar .a1');
	Aconf[city].max = parseInt(jQuery('#cid_'+city+' table .order_toolbar #total').text())+1;
	Acan.storage.set('conf_'+city,Aconf[city]);
	tbj.each(function(i){
		jQuery(this).attr('onclick',jQuery(this).attr('onclick').replace('pageOrderQuery(','city_get(\''+city+'\','));
	});
	var Dbj = jQuery('#cid_'+city+' table tbody tr');
	var data = {};
	Dbj.each(function(i){
		var orderid = jQuery(this).attr('orderid');
		var send = jQuery(jQuery(this).find('td').get(1)).text();
		var order = jQuery(jQuery(this).find('td').get(2)).text();
		var recv = jQuery(jQuery(this).find('td').get(3)).text();
		var status = jQuery(jQuery(this).find('td').get(4)).text();
		var obj={};
		obj.send = city_obj(send);
		if(i==0){
			lasttime = obj.send['客户下单时间'];
		}
		obj.order = city_obj(order);
		obj.recv = city_obj(recv);
		obj.status = city_obj(status);
		data[orderid] = obj;
	});
	if(Agl.mode=='114'){
		post_114(city,data,lasttime);
	}else{
		post_data(city,data,lasttime);
	}
	delete data,Dbj,tbj;
	if(Aconf[city].mode==1){
		var shuaxin = parseInt(Aconf[city].cycle);
		Aui_shuaxin(city,shuaxin);
		jQuery('#Aui_m .-nav ._title span').text(Agl.count);
		setTimeout(function(){
			var citys = jQuery('#cid_'+city).parent().next().children().attr('rel');
			if(!citys) citys = jQuery("#Aui_tabs > div > div").attr('rel');
			city_get(citys);
			Agl.count++;
		},1000*shuaxin);
	}
	return;
}
function city_obj(str){
	var nrr = str.split('\n'),obj={};
	for(var i in nrr){
		var str = nrr[i].replace(/(^\s*)|(\s*$)/g, "");
		var srr = str.split('：');
		if(srr.length>1){
			obj[srr[0]] = srr[1];
		}
	}
	delete nrr;
	return obj;
}
function Aui_addTab(title,html) {
	var id = "Aui_tabs-" + Agl.tabCounter;
	var tabTemplate = "<li><a href='#"+id+"'>"+title+"</a> <span id='ss_"+title+"'></span> <span class='ui-icon ui-icon-close' role='presentation'></span></li>";
//	var li = jQuery( tabTemplate.replace( '{href}', id ).replace( '{label}', title ) );
	var height = jQuery("#Aui_m ._content").height()-40;
	Atabs.find( ".ui-tabs-nav" ).append( tabTemplate );
	Atabs.append( "<div id='" + id + "' class='_body' style='height:"+height+"px;'>"+html+"</div>" );
	Atabs.tabs( "refresh" );
	Agl.tabCounter++;
}
function Aui_closeTab(city){
	jQuery('#ss_'+city).parent().remove();
	jQuery( "#cid_" + city ).parent().remove();
	Atabs.tabs( "refresh" );
}